<?php
include_once('common/header.php');	
$objCommon	= new Vfriend_Common();


$intPage			= $objRequest->getParam('page', 1);
$intFilter			= $objRequest->getParam('filter', -1);
$strKeyword			= $objRequest->getParam('keyword', null);
$strDateFrom 		= $objRequest->getParam('startdate', null);
$strDateTo			= $objRequest->getParam('enddate', null);
$arrSubCategoryId 	= $objRequest->getParam('se_cate', null);
$arrProvince		= $objRequest->getParam('province', null);
$arrDistrict		= $objRequest->getParam('district', null);
if($intFilter > -1 || (isset($strKeyword) && $strKeyword != '') || (isset($strDateFrom) &&  $strDateFrom != '') || (isset($strDateTo) && $strDateTo != '') || isset($arrSubCategoryId) || isset($arrProvince) || isset($arrDistrict)) {	
	$objVfriendUser	= new Vfriend_User();
	$objPlace 	= new Place();	
	$intTotal	= 0;
	$intLimit	= PLACES_LIMIT;
	$arrCate	= array();
	if($arrSubCategoryId) {
		foreach($arrSubCategoryId as $value) {
			$arrCate[$value] = $value;
		}
	}
	$arrProv= array();
	if($arrProvince) {
		foreach($arrProvince as $value) {
			$arrProv[$value] = $value;
		}
	}
	$arrDist= array();
	if($arrDistrict) {
		foreach($arrDistrict as $value) {
			$arrDist[$value] = $value;
		}
	}	
	$strSubCate	= Vfriend_Function::convertArrToStr($arrSubCategoryId);	
	$strProvince= Vfriend_Function::convertArrToStr($arrProv);	
	$strDistrict= Vfriend_Function::convertArrToStr($arrDist);	
	$intOffset	= ($intPage - 1) * $intLimit;
	$arrResult	= $objPlace->getSearch($strSubCate, $intFilter,$strKeyword,$strProvince, $strDistrict, Vfriend_Function::convertStrToDate($strDateFrom),Vfriend_Function::convertStrToDate($strDateTo),$intOffset,$intLimit,$intTotal);
	
	$this->view->arrPlaces	= $arrResult;
	$this->view->intTotal	= $intTotal;
	$this->view->intOffset	= $intOffset;
	$this->view->intLimit	= $intLimit;	
	$this->view->strUrl 	= Vfriend_Function::getUrl();
	$this->view->strKeyword	= $strKeyword;	
	$this->view->startdate	= $strDateFrom;
	$this->view->enddate	= $strDateTo;	
	$this->view->arrCate	= $arrCate;
	$this->view->arrProv	= $arrProv;
	$this->view->arrDist	= $arrDist;	
	$this->view->act		= 1;
}	
$this->view->arrFilter 	= $arrFilter;	
$this->view->intFilter	= $intFilter;
$this->view->arrProvince= $objCommon->getProvince();
	
?>
